<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">

  </div>
  <style>
  </style>
  <script src="https://unpkg.com/vue@next"></script>
  <script>
    const app = Vue.createApp({
      template: `
        <child app="app" @change="handelChange">
          parent
        </child>
      `,
      methods: {
        handelChange() {
          alert('emit')
        }
      },
      setup(props, contxt) {
        let data = {name:'张三'}
        return {
          data
        }
      }
    })
    app.component('child',{
      template: `
        <div @click="handelClick">child</div>
      `,
      setup(props, context) {
        const {h} = Vue;
        const {attrs,slots,emit} = context
        console.log(attrs) // Proxy {app: "app", __vInternal: 1}  获取子组件自定义的数据
        console.log(slots.default()) // Proxy {app: "app", __vInternal: 1}  获取子组件自定义的数据
        // return ()=> h('div',{},slots.default()) // 输出自定义组件插槽的内容
        function handelClick() {
          emit('change')
        }
        return {
          handelClick
        }
      }
    })
    app.mount("#app");
  </script>
</body>

</html>